<template>
	<view :class="[BackGround]" :style="[{'font-weight':Style,'font-family':Font,height:100 + '%',minHeight:height + 'px'}]">
		<cu-custom bgColor="bg-gradual-blue" isBack="true">
			<view slot="backText">返回</view>
			<view slot="content">设备台账详情</view>
		</cu-custom>
		<view :class="['margin-xs radius shadow shadow-lg bg-white' ,BackGroundBox]" v-if="isShow">
			<form @submit="formSubmit" @reset="formReset">
				<view class="cu-form-group">
					<view class="title">编号</view>
					<input type="text" name="LCODE" :value="deliverplan.lcode" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">设备名称</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">使用部门</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">设备名称</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">故障原因</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">处理方法</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">更换备件</view>
					<input type="text" name="LNAME" :value="deliverplan.lname" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">是否有效</view>
					<switch @change="SwitchA" name="lisused" :class="deliverplan.lisused?'checked':''" :checked="deliverplan.lisused?true:false"></switch>
				</view>
				<view class="cu-form-group">
					<view class="title">备注</view>
					<input type="text" name="LREMARK" :adjust-position="false" v-model="deliverplan.lremark" @focus="focus" />
				</view>
				<button-father :Position="'tb-fa-fixed'">
					<button class="cu-btn bg-gradual-red  lg shadow tb-flex cu-btn-new" @tap="deleteall">删除</button>
					<button class="cu-btn bg-gradual-blue  lg shadow tb-flex cu-btn-new" form-type="submit">修改</button>
				</button-father>
			</form>
		</view>
		<!--输入框组件-->
		<zyt-input tui-top-dropdown="tui-top-dropdown" bgcolor="rgba(76, 76, 76, 0.95)" :show="menuShow" :height="0" @close="closeMenu"
		 :zvalue="deliverplan.lremark" @zblur="zblur">
		</zyt-input>
		<!---输入框组件-->
	</view>
</template>

<script>
	import {
		updateForm
	} from "@/service/updateList.js"
	import {
		getselectForm1
	} from "@/service/selectList.js"
	import {
		postdeleteForm
	} from "@/service/deleteList.js"
	import ButtonFather from '@/colorui/components/ButtonFather.vue'
	import {
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				isShow: true,
				height: this.screenHeight,
				menuShow: null,
				lid:"",
				deliverplan: []
			}
		},
		computed: {
			...mapGetters([
				'Style', 'Font', 'BackGround', 'BackGroundBox'
			]),

		},
		components: {
			ButtonFather
		},
		onLoad(option) {
			this.lid= option.lid
			getselectForm1(196).then(res => {
				if (res.code == 1) {
					res.data.forEach((val, index) => {
						val['isShow'] = true
						if (val['lid'] == option.lid) {
							this.deliverplan = val
						}
					})
				}
			})
		},
		methods: {
			PickerChange1(e) {
				this.index1 = e.detail.value
			},
			PickerChange2(e) {
				this.index2 = e.detail.value
			},
			SwitchA(e) {
				this.deliverplan.lisused = e.detail.value
			},
			focus(e) {
				this.menuShow = true
				this.deliverplan.lremark = e.detail.value
			},
			openMenu() {
				this.menuShow = false
			},
			zblur(value) {
				console.log(value);
				this.deliverplan.lremark = value
			},
			closeMenu() {
				this.menuShow = false
			},
			deleteall() {
				postdeleteForm(this.lid).then(res => {
					if(res.code == 1) {
						setTimeout(() => {
							uni.navigateBack({
								delta:1
							})
						},500)
						uni.showToast({
							title:'删除成功',
							icon:'success'
						})
					}
				})
			},
			formSubmit(e) {
				console.log(e.detail.value);
				let data = e.detail.value
				updateForm(data.LCODE, data.LNAME, data.lisused, data.LREMARK, 196, false, this.deliverplan.lid).then(res => {
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
						}, 500)
						uni.showToast({
							title: '修改成功',
							icon: 'success',
							duration: 2000
						})
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: whitesmoke;
	}
</style>
